#lang rosetta-racket


(provide random-graph-coords)


(define (list-random lst)
  (list-ref lst (random (length lst))))

(define (random-neighbour neighbours vi)
  (list-random (vector-ref neighbours vi)))

(define (random-indices neighbours n vi)
  (define (random-indices-rec n vi vis)
    (if (<= n 0)
        vis
        (let ((vi (random-neighbour neighbours vi)))
          (random-indices-rec (- n 1) vi (cons vi vis)))))
  (random-indices-rec n vi (list)))

(define (random-vertices vertices neighbours n)
  (map
   (cλ vector-ref vertices)
   (random-indices neighbours n (random (vector-length vertices)))))

(define (random-graph-coords vertices neighbours n)
  (random-vertices vertices neighbours n))